package com.yxkj.syh.app.huarong.adps;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.syh.app.basic.utils.ComUtil;
import com.yxkj.syh.app.huarong.R;
import com.yxkj.syh.app.huarong.bean.PayOrderDetailInfo;

import java.util.ArrayList;
import java.util.List;

/**
 * 创建者：SYH
 * 时间：2020/5/26 15:26
 * 编辑者：SYH、
 * 标签：
 * 补充说明：
 */
public class PayOrderDetail1Adp extends RecyclerView.Adapter<PayOrderDetail1Adp.ViewHolder> {
    List<PayOrderDetailInfo> data = new ArrayList<>();


    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_pay_order_detail_1, null);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        PayOrderDetailInfo info = data.get(position);

        holder.tvTitle.setText(info.getTitle());
        holder.tvValue.setText(ComUtil.clearNoUseZero(info.getPrice()).toPlainString() + "元");
    }

    public void setNewData(List<PayOrderDetailInfo> infos) {
        data.clear();
        data.addAll(infos);
        notifyDataSetChanged();
    }

    public List<PayOrderDetailInfo> getData() {
        return data;
    }

    @Override
    public int getItemCount() {
        return data.size();
    }


    public class ViewHolder extends RecyclerView.ViewHolder {
        TextView tvTitle, tvValue;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            tvTitle = itemView.findViewById(R.id.tvTitle);
            tvValue = itemView.findViewById(R.id.tvValue);
        }
    }

}
